
/*********************************************************************************************************************************************
* CLASS NAME : BCCore
* 
* PURPOSE : 
*
* - Creates the main window
* - Creates the DX9 device
* - Handles User inputs and events
*
* Derived From : This is the base class
**********************************************************************************************************************************************/




#ifndef BC_CORE_H
#define BC_CORE_H

#include "dependancies.h"
#include "BC_Vector2d.h"
#include "BC_Debugger.h"

// enumeration for scene mode sets what happens when you set specific flag...
// 
enum eSceneMode
{
	BC_SCENEMODE_MENU ,
	BC_SCENEMODE_GAME ,
	BC_SCENEMODE_GAMEOVER,
	BC_SCENEMODE_HIGHSCORE,
};





class BCCore
{

	public :

		virtual ~BCCore();
		
		/*********************************************************************
		* GLOBAL METHODS :
		**********************************************************************/
		
		void setWindowTitle(const std::string& title);

		// returns the handle of the window.In some cases can be useful...
		HWND getWindowHandle();

		// Returns the dx device.All the rendering stofe is done inside the Game class , however
		// an option to retreive the dx device pointer is always a handy function...
		LPDIRECT3DDEVICE9 getDXDevice();


		// switches between fullscreen and window mode :
		void enableFullscreen(int newWidth , int newHeight , int depth , bool enable);


		/*********************************************************************
		* INPUT HANDLING :
		**********************************************************************/

		bool isKeyPressed(char keycode);
		bool isKeyHit(char keycode);
		bool isLastPressed(char keycode);

		bool mouseLeftDown();
		bool mouseRightDown();
		int mouseWheel();
		bool mouseRightClick();
		bool mouseLeftClick();
		
		// Returns the mouse coordinates relative to the main window :
		BCVector2d getMouseLocalPos();

		// Returns the mouse coordinates relative to desktop :
		BCVector2d getMouseGlobalPos();

	protected :

		BCCore(int winWidth , int winHeight , int winDepth , bool fullscreen);
	
		// array for keycodes :
		bool keycodeBuffer[256];

		bool mouseLState;
		bool mouseRState;
		int wheelState;
		int mposx , mposy;
		
		std::list<char> keyList;

		// mouse movement delta
		int mDeltaX , mDeltaY;

		// The mainWindow's handle
		HWND window;

		// DX9 device :
		LPDIRECT3DDEVICE9 device;
		
		// the pointer to our Direct3D interface
		LPDIRECT3D9 d3d;

		// true if user presses the close button on the window
		static bool windowClosing;

		// Message callback for winapi :
		static LRESULT CALLBACK BCWinCallback(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

};










#endif










